package org.flower.isme.flower.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.flower.isme.common.response.Page;
import org.flower.isme.flower.domain.entity.EnvironmentData;
import org.flower.isme.flower.domain.request.EnvironmentDataPageRequest;
import org.flower.isme.flower.service.EnvironmentDataService;
import org.flower.isme.flower.mapper.EnvironmentDataMapper;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class EnvironmentDataServiceImpl extends ServiceImpl<EnvironmentDataMapper, EnvironmentData>
    implements EnvironmentDataService{

    /**
     * 分页查询环境数据
     *
     * @param request 查询信息
     * @return Page
     */
    @Override
    public Page<EnvironmentData> queryPage(EnvironmentDataPageRequest request) {
        IPage<EnvironmentData> page = request.toPage();
        IPage<EnvironmentData> environmentDataIPage = baseMapper.selectPage(page, null);
        return Page.convert(environmentDataIPage);
    }

    /**
     * 获取环境数据列表
     *
     * @return List
     */
    @Override
    public List<EnvironmentData> listEnvirmentData() {
        return lambdaQuery().orderByAsc(EnvironmentData::getId).last("limit 10").list();
    }
}




